<template>
  <div class="lock">
    <div class="lock-info">
        <div class="lock-pic">
            <img class="lock-img" :src="icon">
            <div>{{name}}</div>
        </div>
        <div class="lock-comment">{{wifiName}}</div>
    </div>
    <van-button class="lock-btn" @click="lock" :loading="loading" type="primary"  size="large">{{btn_text}}</van-button>
    <div class="lock-tip">{{wifiTip}}</div>
  </div>
</template>
<script>
export default {
  name: 'lock',
  comments: 'lock',
  data () {
    return {
      name: 'Lady健身女王',
      icon: './static/images/Wechat.jpeg',
      wifiName: 'Lady健身女王开锁',
      wifiTip: '目前只支持微信开锁',
      loading: false,
      btn_text: '一键开锁'
    }
  },
  created () {
    document.title = '在线开锁'
  },
  methods: {
    // 开锁
    lock: function () {
      this.loading = true
      var that = this
      setTimeout(() => {
        that.loading = false
      }, 1000)
      this.$axios.post('locks/' + 1 + '/open', {
        user_id: JSON.parse(localStorage.getItem('user')).id
      }).then(response => {
        // var config = response.data
        that.$toast(response.data)
        that.loading = false
      })
    }
  }
}
</script>
<style lang="postcss" scoped>
.lock-info{
    margin-top: 20%;
}
.lock-img{
    width: 50px;
    height: 50px;
    border-radius: 50%;
}
.lock-success{
    font-size: 4rem;
    color: #06bf04;
}
.lock-comment,.lock-tip{
    font-size: 0.5rem;
    color: #999;
    margin-top: 5px;
}
.lock-btn{
    width: 60%;
    margin-top: 40px;
}
</style>
